#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#define int long long

using namespace std;

bool cmp(string s1,string s2)
{
    return s1 + s2 > s2 + s1;
}

void solve()
{
    string str3;
    int n;
    cin >> n;
    vector<string> a(n);
    for(int i = 0 ; i < n; i++) cin >> a[i];
    sort(a.begin() , a.end() , cmp);
    for(int i = 0; i < n; i++)
    str3 += a[i];
    cout << str3 <<endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- )  solve();
    return 0;
}